﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Net;
using System.Windows.Forms;

namespace SystemUpdate
{
    public partial class Step2FTP : UserControl
    {
        private DownloadFromFTP from = new DownloadFromFTP();
                
        public Step2FTP()
        {
            (Program.mainForm as SystemUpdateForm).downloadFrom = from;
            from.Settings = (Program.mainForm as SystemUpdateForm).Settings;

            InitializeComponent();
            try
            {
                this.textBox1.DataBindings.Add("Text", from.Settings, "SourceServer", true);
                this.textBox2.DataBindings.Add("Text", from.Settings, "SourceFile", true);
                this.checkBoxCred.DataBindings.Add("Checked", from.Settings, "SourceAuthenticationIsRequried", true);
                this.UserName.DataBindings.Add("Text", from.Settings, "SourceUser", true);
                this.Password.DataBindings.Add("Text", from.Settings, "SourcePassword",true);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }

        private void checkBoxCred_CheckedChanged(object sender, EventArgs e)
        {
            this.UserName.Enabled = (sender as CheckBox).Checked;
            this.Password.Enabled = (sender as CheckBox).Checked;
        }

        private void buttonProxy_Click(object sender, EventArgs e)
        {
            from.SetupProxy();
        }
    }
}
